
{extend name="index/index"/}


{block name="main"}
<div class=" admin-content">
<div class="admin-biaogelist">
	
    <div class="listbiaoti am-cf">
      <ul class="am-icon-flag on"> 友情链接列表</ul>
      
      <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">友情链接列表</a></dl>
      
      <dl>
        <a type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus" href="{:url('admin/friend/create')}"> 添加连接信息</a>
      </dl>

    </div>
	


          <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
            <thead>
              <tr class="am-success">
                <th class="table-id">ID</th>
                <th class="table-title">链接名</th>
                <th class="table-type">链接地址</th>
                <th class="table-author am-hide-sm-only">创建时间</th>
                <th class="table-date am-hide-sm-only">备注/描述</th>
                <th width="163px" class="table-set">操作</th>
              </tr>
            </thead>
            <tbody>
            {volist name="data" id="v"}
              <tr>
                <td>{$v['id']}</td>
                <td>{$v['webname']}</td>
                <td>{$v['url']}</td>
                <td class="am-hide-sm-only">{$v['dtime']}</td>
                <td class="am-hide-sm-only">{$v['msg']}</td>
                <td><div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">

                      <a class="am-btn am-btn-default am-btn-xs am-text-secondary am-round" href="{:url('admin/friend/edit',['id'=>$v['id']])}"><span class="am-icon-pencil-square-o"></span></a>

                      <button data-id="{$v['id']}" class="am-btn am-btn-default am-btn-xs am-text-danger am-round btn-del"><span class="am-icon-trash-o"></span></button>
                    </div>
                  </div></td>
              </tr>
            {/volist}
            </tbody>
          </table>

          <ul class="am-pagination am-fr">
              {$data->render()}
          </ul>

</div>

</div>
<script>
   $(function(){
        $('.btn-del').click(function(){
              var ac_id = $(this).attr('data-id');
//              console.log(ac_id);

              if(confirm('你确定要删除这个链接吗？')){

                  var obj = $(this).parents('tr');

                  delAjax(ac_id,obj);
              }

        });

        //执行ajax操作
       function delAjax(id,obj)
       {
         $.ajax({
               type: 'delete',
               url : '/friend/'+id,
               datatype : 'json',
               success: function(data){
                   if (data.status) {
                      alert(data.info);
                       // 将当前的节点删除掉
                       obj.remove();
                   } else {
                       alert(data.info);
                   }
               },
               error : function(){
                   alert('ajax请求失败');
               }



         });
       }
   }) ;



</script>
{/block}